home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1255 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: norconnect.no!not-for-mail
  2. From: kenneth@norconnect.no (Kenneth C. Nilsen)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: How works SetFunction ?
  5. Date: 17 Jan 1996 07:00:17 +0100
  6. Organization: NorConnect Internet Services AS
  7. Message-ID: <1619.6590T362T1266@norconnect.no>
  8. References: <30fb3c06@beachyhd.demon.co.uk>
  9. NNTP-Posting-Host: norconnect.no
  10. X-Newsreader: THOR 2.21 (Amiga;SOUP)
  11.  
  12. >In a message of 14 Jan 96 UNREGISTERED VERSION wrote to All:
  13.  
  14.  UV>>   oldfunc=SetFunction(library,oldFuncOffset,newFuncPtr)
  15.  UV>>   what is oldFuncOffset?
  16. >It is the offset in the library that you would jump to (in assembler) to call
  17. >the library function. For example, the Open() function in dos.library has an
  18. >offset of -30.
  19.  
  20. No no, the oldFuncOffset is the actual pointer to the routine code of the old
  21. function. This will let you use the old function in your new routine:
  22.  
  23. Here is an example. We have already opened intuition.library:
  24.  
  25.     [...]
  26.  
  27.     move.l    $4.w,a6
  28.  
  29.     move.l    IntuitionBase(pc),a1
  30.     move.l    #_LVOOpenWindowTagList,a0
  31.     move.l    #OpenMywin,d0
  32.     Call    SetFunction
  33.     move.l    d0,OldFunc
  34.     beq.w    Close
  35.  
  36.     [...]
  37.  
  38. Close    move.l    $4.w,a6
  39.  
  40. ;remember to make a routine to check if it's okay to set back the old function
  41. ;For that you need to compare the pointer you get after the next routine.
  42. ;if that and the OldFunc are not equal you cannot exit. Set back the pointer
  43. ;you get last and try again later..
  44.  
  45.     move.l    OldFunc(pc),d0
  46.     beq.b    .noFunc
  47.     move.l    IntuitionBase(pc),a1
  48.     move.l    #_LVOOpenWindowTagList,a0
  49.     Call    SetFunction
  50.  
  51. .noFunc    rts
  52.  
  53.  
  54. OpenMywin:
  55.  
  56.     movem.l    a2-a6/d2-d7,-(sp)
  57.  
  58.     move.l    OldFunc(pc),a5    ;if the routine uses the A5 register DON'T
  59.     jsr    (a5)        ;use this registre..
  60.  
  61.     movem.l    (sp)+,a2-a6/d2-d7
  62.     rts
  63.  
  64. This will do as the original function, but here you can manipulate the data
  65. before and after.
  66.  
  67.  
  68. ---
  69. CREATIVE LINKS                       __     Kenneth C. Nilsen
  70. http://www.norconnect.no/~kenneth   /_/\    e-mail: kenneth@norconnect.no
  71. "Everything you want"               \_\/    Software & MultiMedia developer
  72.  
  73.